package cn.itsource.ymcc.web.controller;


import cn.itsource.ymcc.dto.SMSSendParamDto;
import cn.itsource.ymcc.result.JSONResult;
import cn.itsource.ymcc.service.IVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService ;


    @GetMapping("/imageCode/{imageCodeKey}")
    public JSONResult createImageCode(@PathVariable("imageCodeKey")String imageCodeKey){
        //返回图片Base64编码的字符串
        String base64ImgStr = verifyCodeService.createImageCode(imageCodeKey);
        return JSONResult.success(base64ImgStr);
    }

    //短信验证码
    @PostMapping("/sendSmsCode")
    public JSONResult sendSmsCode(@RequestBody SMSSendParamDto dto){
        verifyCodeService.sendSmsCode(dto);
        return JSONResult.success();
    }
}